package haupt.dev.NeocronServiceQuery;

import org.pmw.tinylog.Logger;

import haupt.dev.Config.ConfigFileReader;
import haupt.dev.Config.ConfigReader;
import info.neocron.service.SessionManagement.SessionDetails;
import info.neocron.service.SessionManagement.SessionManagement;
import info.neocron.service.SessionManagement.SessionManagementSoap;

public class AccountManager {

	public static String getSessionToken() {
		ConfigReader CFGreader = new ConfigFileReader();
		String login = CFGreader.getProperty("gameAccount");
		String pwd = CFGreader.getProperty("gamePassword");
		SessionManagement sessionManagementService = new SessionManagement();
		SessionManagementSoap sessionManagementSoap = sessionManagementService.getSessionManagementSoap();
		SessionDetails sessionDetails = sessionManagementSoap.login(login, pwd);
		String token = sessionDetails.getToken();
		if(token == null || token.isEmpty()) {
			Logger.warn("Sorry, can't catch token from SOAP. Account-User and account-password correct?");
		}
		return token;
	}
}
